1. Field of the Invention
The present invention relates to an instruction control method in a computer system, and more specifically to a branch instruction control apparatus and a control method in which new entries are made and a flag required for the control of a branch instruction is updated in accordance with the release of entries as an entry control method for a branch reservation station for controlling a branch instruction, and entries are rearranged by a bubble-up mechanism, in a computer in which an out-of-order method is adopted.
2. Description of the Related Art
When an instruction is controlled in an instruction control apparatus, an instruction which has been inputted to an implementation pipeline in advance sometimes affects the implementation of succeeding instructions. When the succeeding instructions are implemented based on the implementation results of the preceding instruction, if the processing of the preceding instruction is delayed, no succeeding instructions can be implemented during that time, and the succeeding instructions must keep waiting for the completion of the preceding instruction. In this way, a branch instruction in particular, among instructions which affect the implementation of succeeding instructions, greatly affects the succeeding instructions. When the preceding instruction which has been implemented in advance is an instruction which is going to change branch conditions, unless the implementation results of that instruction are not fixed, it is not possible to judge whether a branch exists or not. If it is not possible to judge whether a branch exists or not, the sequence of the succeeding instructions of the branch instruction cannot be established.
As a result, the succeeding instructions cannot be inputted to the implementation pipeline, so that the processing within the instruction control apparatus stops temporarily, thus causing the processing capability to be reduced. This also applies to an instruction control apparatus which adopts any other processing method, and is the problem common to any instruction control apparatus. In order to solve this problem, usually, an instruction control apparatus holds a branch prediction mechanism. By predicting a branch, it is possible to input the succeeding instruction sequences of the branch instruction one after another to the implementation pipeline without waiting for the completion of the branch instruction.
In the case of an out-of-order processing method having a branch prediction mechanism, a plurality of branch instructions are inputted to the implementation pipeline based on branch prediction results. The branch instructions which are inputted to the implementation pipeline are controlled in a branch instruction control unit. The branch instruction control unit can control a plurality of branch instructions, but there is an upper limit in the number of branch instructions which can be controlled at a time. If the processing of branch instructions is delayed, the resources of the branch instruction control unit decrease gradually, and when the number of branch instructions which are inputted to the implementation pipeline reach the upper limit of the number of entries which can be processed at the same time, no new instruction can be inputted to the pipeline any more.
In such a case, since the succeeding instruction sequences cannot be inputted to the implementation pipeline even if the prediction in the branch prediction mechanism is correct, the processing capability decreases. In order to solve this problem, it is necessary to improve the throughput of the branch instruction processing in the branch instruction control unit and increase the number of branch instructions which can be controlled by the branch instruction control unit at the same time. However, merely by increasing the number of branch instructions (entries) which can be controlled by the branch instruction control unit at the same time, the throughput of the branch instructions cannot be improved, for example, when a toothless state of entries takes place as described later.
When the instruction control apparatus is controlled by the out-of-order method, all the instructions are controlled by the instruction control unit called a reservation station. A plurality of reservation stations exist in the instruction control unit, and by which reservation station an instruction is controlled is determined depending on the kind of the instruction. A pointer method or a bubble-up method is a general method for controlling entries of a reservation station. When entries are controlled by the pointer method, it is possible to effectively use the number of entries which are limited resources without waste, but there is a demerit in that the pointer method cannot easily cope with the tendency of high frequencies used in instruction control apparatuses in recent years.
Each entry of the reservation station is controlled by a VALID signal indicating that the entry is valid or invalid. When entries are controlled by the bubble-up method, unless the VALID signal is 0 (zero) and the entries are invalid, succeeding instructions could not use the entries in prior art. Consequently, until the entries are released (reset) and the succeeding instructions can come to use the entries, the entries are toothless temporarily, and useless cycles in which part of entries cannot be used are generated.
When an branch instruction is controlled by a reservation station, entries must be released in order. Therefore, the entries in the reservation station must always line up in the order of instructions. When the entries of a branch reservation station are controlled by the bubble-up method, if the entries become toothless temporarily after the entries are released and the entries cannot be used effectively, the entries reach the seeming upper limit of the number of entries, so no new instruction can be inputted to the implementation pipeline. Moreover, unless no succeeding instruction can be registered to the branch reservation station although, in fact, there is some space in the entries, the throughput of the branch instruction decreases, thus causing the performance of an instruction control apparatus to be decreased.
The prior art of the branch instruction control method which uses such a branch reservation station that has been described above is explained below using FIG. 1 to FIG. 5. FIG. 1 is an example showing the release of entries in a branch reservation station and the process of making a new entry in accordance with the input of a new instruction in prior art.
A total of ten entries, for example, from RSBR0 to RSBR9 are provided in the branch reservation station. In a first cycle, data or flags required for the control of branch instruction 1 to branch instruction 6 are stored for six entries from RSBR0 to RSBR5; branch instruction 7 and branch instruction 8 are going to be inputted to RSBR6 and RSBR7 respectively from the side of the decoder; and the control is going to be completed for branch instruction 1 to branch instruction 3.
In the following cycle, three entries from RSBR0 to RSBR2 in which flags, etc. for three branch instructions whose implementation control has been completed are stored are released; flags, etc. for branch instruction 7 and branch instruction 8 are stored for RSBR6 and RSBR8; and new entries are going to be made in RSBR8 and RSBR9 for branch instruction 9 and branch instruction 10 which are inputted from the side of the decoder.
In the following cycle, bubbling-up is carried out, and the contents of each entry are moved in a direction toward the top entry. In prior art, this bubbling-up is carried out after the entry positioned in a direction toward the top entry is released and the VALID flag for the released entry is lowered. Consequently, the bubbling-up is carried out after it is confirmed that the entries from RSBR0 to RSBR2 have been released and the VALID flag has been lowered.
In the bubbling-up here, it is supposed that the contents of an entry are moved in a direction toward the top entry by the number of one entry for each of the entries. The flags, etc. for branch instructions from branch instruction 4 to branch instruction 8 are stored in the entries from RSBR2 to RSBR6. Then, data for branch instruction 9 and branch instruction 10 which were going to be newly inputted to RSBR8 and RSBR9 in the preceding cycle is stored, that is to say, new entries are made.
As a result, RSBR0, RSBR1 and RSBR7 out of ten entries are empty, that is to say, toothless. So, when trying to input new branch instructions from the side of the decoder in this cycle, there is no empty entry on the rear end side of the branch reservation station, and no new branch instruction can be inputted in the implementation pipeline.
FIG. 2 to FIG. 5 show part of the control circuit corresponding to a conventional technology of FIG. 1. In order to compare the conventional control circuits shown in these figures with the control circuits of the present invention which will be explained later, described below is the operation of these control circuits (shown in FIG. 2 to FIG. 5).
FIG. 2 shows a bubble-up control signal output circuit (No. 1). In the prior art shown in FIG. 1, all the entries from RSBR0 which is the top entry to RSBRm which is the (m+1) th entry exist in the branch reservation station. In other words, when flags, etc. are stored, a disabled bubble-up signal indicating bubble-up inability is outputted from the buffer 100. In the prior art shown in FIG. 1, bubbling-up is carried out in the form in which the contents of an entry are moved in a direction toward the top entry by the number of one entry for each of the entries, so bubbling-up is impossible when data is stored continuously in all the entries from the top entry to the (m+1)th entry.
FIG. 3 shows a bubble-up control signal output circuit (No. 2). In FIG. 3, when all the entries from RSBR0 to RSBRm does not exist, that is to say, when data is not stored in all the entries, that is to say, when there is even a single empty entry on the way, an enable_1up signal indicating that the bubbling-up of the entry following the empty entry is possible is outputted from the buffer 101.
FIG. 4 shows the output circuit of a load permitting (enabling) signal for data for RSBRm from the decoder. In FIG. 4, when a VALID signal indicating that RSBR (m−1) is valid for the AND gate 102, and a signal indicating that entries from RSBRm to RSBRn which is the last entry do not exist, that is to say, these entries are empty are inputted, loading of data such as a flag in the entry RSBRm is permitted from the decoder.
FIG. 5 shows the latch circuit holding data such as a flag required for the control of branch instructions as the entry of the branch reservation station. FIG. 5 corresponds to the RSBR0 of the top entry, and in the prior art shown in FIG. 1, the same type latch circuit as shown in FIG. 5 is used in correspondence with the three entries from the top entry to RSBR2.
In FIG. 5, a set signal which sets data such as a flag to the entry of RSBR0 is given to the set terminal. When a COMPLETE signal indicating that the branch instruction for the entry of RSBR0 via the OR gate 104 has been completed, a CLEAR signal which releases the entry of RSBR0 when re-instruction fetching is required as will be described later, and RS1 as a RESET signal used for interrupt, etc. are inputted to a reset terminal, and when these signals become H (1), a reset is executed. The COMPLETE signal of RSBR0 resets the contents of the latch 103, but basically, it is used to lower the VALID flag in order to carry out bubbling-up as described above.
In the configuration of the latch circuit for seven entries from RSBR3 to RSBR9, the difference lies only in that only a COMPLETE signal as the entry of the OR gate 104 is excluded. This is because in prior art of FIG. 1, when the control of branch instructions is completed, the entries which are released are limited to three entries from RSBR0 to RSBR2, and entries which are released at the same time are limited to one or more entries which can be released continuously from the top entry.
The following document is available as the prior art concerning the out-of-order instruction control method.
Patent document 1: Kokai (Jpn. unexamined patent publication) No. 2000-181707 “Instruction Control Apparatus and Method”
In this document, an instruction control apparatus is disclosed in which a reservation station in which a plurality of instructions which have been decoded and which have not been issued to the implementation unit are stored temporarily is provided, and in which information stored in entries is moved by the bubble-up method for the reservation station. However, even in this technology, the problem was not solved in that entries become toothless with the operation method in which bubbling-up is carried out after the VALID flags of the entries which have been released are lowered as described in FIG. 1.